package com.jk.controller;

import com.jk.entity.AreaEntity;
import com.jk.entity.UserEntity;
import com.jk.service.ClothService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * 类描述：
 *
 * @ClassName ClothController
 * @Description TODO
 * @Author fandasen
 * @Date 2022/5/30 17:43
 * @Version 1.0
 */
@RestController
@RequestMapping("cloth")
public class ClothController {

    @Autowired
    private ClothService clothService;


    /**
     * 登录
     * @param user
     * @param sesssion
     * @return
     */
    @RequestMapping("login")
    public Object login(@RequestBody UserEntity user, HttpSession sesssion){
        return clothService.login(user,sesssion);
    }





    /**
     * 注册三级联动
     * @param pid
     * @return
     */
    @RequestMapping("getprovince")
    public List<AreaEntity> getprovince(@RequestParam Integer pid){
        return clothService.getprovince(pid);
    }

    /**
     * 发送验证码
     * @param phone
     * @return
     */
    @RequestMapping("gainCode")
    public String gainCode(@RequestParam String phone){
        return clothService.gainCode(phone);
    }

    /**
     * 手机号注册
     * @param user
     * @param session
     * @return
     */
    @RequestMapping("phoneRegister")
    public String phoneRegister(@RequestBody UserEntity user,HttpSession session){
        return clothService.phoneRegister(user,session);
    }

    /**
     * 登录
     * @param user
     * @return
     */
    @RequestMapping(value = "register")
    public String register(@RequestBody UserEntity user){
        return clothService.register(user);
    }
}
